#pragma once

#include <memory>

namespace Cache {

template <typename Key, typename Value>
class ArcNode {
  private:
    Key key_;
    Value val_;
    size_t accessCnt_;
    std::weak_ptr<ArcNode> prev_;
    std::shared_ptr<ArcNode> next_;

  public:
    ArcNode() : accessCnt_(1), next_(nullptr) {}

    ArcNode(Key key, Value val) : key_(key), val_(val), accessCnt_(1), next_(nullptr) {}

    Key getKey() const { return key_; }
    Value getValue() const { return val_; }
    size_t getAccessCount() const { return accessCnt_; }

    void setValue(const Value &value) { val_ = value; }
    void incrementAccessCount() { ++accessCnt_; }

  public:  //! public 和 private 没有区别
    template <typename K, typename V>
    friend class ArcLruPart;
    template <typename K, typename V>
    friend class ArcLfuPart;
};

}  // namespace Cache
